package hfjava;

import java.util.Scanner;

public class Guess_Test {
    public static void main(String[] args) {
        Guess tv1=new Guess();
        tv1.name="小米电视";
        tv1.price=3399.0;
        Guess tv2=new Guess();
        tv2.name="小米电视";
        tv2.price=5999.0;
        Guess tv3=new Guess();
        tv3.name="小米电视";
        tv3.price=12999.0;
        Scanner input=new Scanner(System.in);
        System.out.println("请输入1-3随意一个数");
        int num=input.nextInt();
        int count=0;
        if (num==1){
            for (int i = 0; i <4 ; i++) {
                count++;
                if (count>3){
                    System.out.println("失败了");
                    break;
                }
                System.out.println("请猜价格");
                double price=input.nextDouble();
                String str=tv1.guess(price);
                System.out.println(str);
                if ("猜中了".equals(str)){
                    break;
                }
            }
        }
        if (num==2){
            for (int i = 0; i <4 ; i++) {
                count++;
                if (count>3){
                    System.out.println("失败了");
                    break;
                }
                System.out.println("请猜价格");
                double price=input.nextDouble();
                 String str=tv2.guess(price);
                System.out.println(str);
                if ("猜中了".equals(str)){
                    break;
                }
        } }
        if (num==3){
            for (int i = 0; i <4 ; i++) {
                count++;
                if (count>3){
                    System.out.println("失败了");
                    break;
                }
                System.out.println("请猜价格");
                double price=input.nextDouble();
                String str=tv3.guess(price);
                System.out.println(str);
                if ("猜中了".equals(str)){
                    break;
                }
        }}


    }
}
